package com.newgrand.ng5.web.controller;

import com.newgrand.ng5.service.TestMyBatisPlusService;
import com.newgrand.ng5.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;


/**
 * @author ：minyang
 * @date ：Created in 2019/8/15 11:47
 */
@RestController
@RequestMapping("/test")
public class TestController {

    @Autowired
    TestService testService;

    @Autowired
    TestMyBatisPlusService testMyBatisPlusService;

    @GetMapping("/demo1")
    public String demo1(HttpServletRequest req) {
        try {
//            String account = (String) req.getAttribute("account");
//            int tenantId = (int) req.getAttribute("tenantId");
            return testService.test1();
        } catch (Exception e) {
            return "exception";
        }
    }

    @GetMapping("/demo2")
    public String demo2(HttpServletRequest req) {
        try {
            testService.testCommonInsert();
            return "success";
        } catch (Exception e) {
            return "exception";
        }
    }

    @GetMapping("/demo3")
    public String demo3(HttpServletRequest req) {
        try {
            testService.testCommonSelect();
            return "success";
        } catch (Exception e) {
            return "exception";
        }
    }

    @GetMapping("/demo4")
    public String demo4(HttpServletRequest req) {
        try {
            testMyBatisPlusService.testPage();
            return "success";
        } catch (Exception e) {
            return "exception";
        }
    }


}
